package ${content.items.serviceImpl.packageName};
<#assign assign_ClassName = content.items.serviceImpl.className>
<#assign assign_EntityName = content.items.entity.className>
<#assign assign_daoName = content.items.dao.camelName>
<#assign tableName = content.content.tableName>
<#assign camelName = content.content.camelName>
import lombok.extern.slf4j.Slf4j;
import com.ibp.common.core.redis.RefershRedisCache;
import com.ibp.common.core.domain.entity.T00User;
import com.ibp.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ibp.common.utils.userPermission.UserPermissionUtil;
import org.apache.commons.lang3.StringUtils;
import java.util.List;
import ${content.items.service.packageName}.${content.items.service.className};
import ${content.items.dao.packageName}.${content.items.dao.className};
import ${content.items.entity.packageName}.${content.items.entity.className};

/**
 * ${tableName}接口的默认实现
 * @author ist
 *
 */
@Slf4j
@Service("${content.items.service.className?uncap_first}")
public class ${assign_ClassName} implements ${content.items.service.className} {

	@Autowired
	private ${content.items.dao.className} ${camelName}DAO;
	@Autowired
	private RefershRedisCache refershRedisCache;

	//数据转换<#--要转换的bean公共BaseEntity-->
	private void formatDataList(List<${assign_EntityName}> list) {
		for(${assign_EntityName} entity:list){
			//判断创建人是否为空
			if(refershRedisCache.cacheUserList.get(entity.getCreateBy()) != null){
				entity.setCreateByDisp(refershRedisCache.cacheUserList.get(entity.getCreateBy()).getRealname());
			}
			//判断录入机构是否为空
			if(refershRedisCache.cacheOrgan.get(entity.getCreateDeptid()) != null){
				entity.setCreateDeptidDisp(refershRedisCache.cacheOrgan.get(entity.getCreateDeptid()).getOrganname());
			}
		}
	}


	//获取列表数据
	public List<${assign_EntityName}> query${camelName?cap_first}List(${assign_EntityName} ${camelName}){
		String sql = UserPermissionUtil.getUserPermissionSql();
		${camelName}.setPermissionSql(sql);//数据权限
		List<${assign_EntityName}>  list= ${camelName}DAO.query${camelName?cap_first}List(${camelName});
		formatDataList(list);
		return  list;
	}
<#if content.content.primaryField??>
	<#assign assign_idFieldType = content.content.primaryField[0].fieldType>
	<#assign assign_idFieldName = content.content.primaryField[0].fieldName>

	//获取详情
	public ${assign_EntityName} query${camelName?cap_first}(${assign_idFieldType} ${assign_idFieldName}){
		${assign_EntityName} ${camelName}= ${camelName}DAO.query${camelName?cap_first}(${assign_idFieldName});
		return  ${camelName};
	}

	//新增
	@Transactional
	public void add${camelName?cap_first}(${assign_EntityName} ${camelName}) {
		//T00User user = SecurityUtils.getLoginUser().getUser();//获取登录用户信息
		${camelName}DAO.add${camelName?cap_first}(${camelName});
	}

	//更新
	@Transactional
	public void modify${camelName?cap_first}(${assign_EntityName} ${camelName}) {
		//T00User user = SecurityUtils.getLoginUser().getUser();//获取登录用户信息
		${camelName}DAO.modify${camelName?cap_first}(${camelName});
	}

	//删除
	@Transactional
	public void delete${camelName?cap_first}(${assign_idFieldType} ${assign_idFieldName}) {
		${camelName}DAO.delete${camelName?cap_first}(${assign_idFieldName});
	}
</#if>

}
